
<script>

import list_remote from './mixin/list_remote'
export default {
  name: 'radio_group_auto',
  mixins: [list_remote],
  render: function (h) {
    let props = Object.assign({ value: this.value, }, this.$attrs, this.attrs)
    return h('el-radio-group', { props, on: { input: (e) => this._emitValue(e) }, }, 
     this._actualList.map((it, i) => { 
      return h(this.button?'el-radio-button':'el-radio', this._childItemProps(it, i), it._label) 
    }))
  },

  props: {
    value: null,
    border: Boolean,
    button:Boolean,
    attrs: Object,
  },
  computed: {

  },

  methods: {
    _emitValue(value, list) {
      if (!list) list = ['input', 'changeItem']
      list.forEach(key => {
        if (key == 'changeItem') {
          this.$emit(key, _.find(this._actualList, (it) => it == value || it._value == value))
        } else {
          this.$emit(key, value)
        }
      })

    },
    _childItemProps(it, i) {
      let label = it._label
      let value = it._value

      return { props: { disabled: !!it.disabled, label: value, border: this.border }, }
    },
    _mainRender(h) {

    },
  }
}
</script>
<style ></style>
